﻿$(document).ready(function () {
	drawRestaurantGrid();
});

function drawRestaurantGrid() {
	var $gridMyRestaurants = $("#gridMyRestaurants").kendoGrid({
		dataSource: {
			type: "aspnetmvc-ajax",
			transport: {
				read: {
					url: "Owner/getRestaurantList"
				}
			},
			error: function (e) {
				document.write(e.xhr.responseText);
			},
			schema: {
				model: {
					fields: {
						Restaurant: { type: "object" }
					}
				},
				data: "Data",
				total: "Total",
				errors: "Errors"
			},
			serverPaging: true,
			serverSorting: true,
			serverGrouping: true,
			serverFiltering: true
		},
		groupable: {
			messages: {
				empty: "Arrastre una columna para agrupar."
			}
		},
		height: 450,
		sortable: true,
		selectable: true,
		resizable: true,
		reorderable: true,
		filterable: true,
		pageable: {
			pageSize: 50,
			pageSizes: [10, 50, 100]
		},
		columns: [
			{ field: "Name", title: "Restaurante" },
            { field: "Address", title: "Direccion" },
            { field: "Telephone", title: "Telefono" },
            { field: "Points", title: "Calificacion" },
            { field: "Category.Description", title: "Categoria" },
            { field: "Open_time", title: "Abre" },
			{ field: "Close_time", title: "Cierra" },
            { field: "Open_days", title: "Dias" },
            { field: "Description", title: "Descripcion" }
		]
	}).data("kendoGrid");

}